﻿using System;
using System.Web.Mvc;
using QDT.Web.Code;

namespace QDT.Web.Controllers
{
    public class ImageController : Controller
    {

        public ActionResult GetImage(string file, string sign = "e5RPVsWJ")
        {
            try
            {
                if (!sign.Equals("e5RPVsWJ") && !QDTContext.Current.IsAuthenticated)
                {
                    return RedirectToAction("LogIn", "Account", new { ReturnUrl = Request["ReturnUrl"] });
                }
                var path = System.Configuration.ConfigurationManager.AppSettings["ImageSavePath"];
                var dirPath = path + "image";
                var filePath = dirPath + file;
                Response.ContentType = "image/jpg";
                Response.WriteFile(filePath);
                Response.End();
                return null; 
            }
            catch (Exception)
            {
                return null;
            }
        }

        public ActionResult GetThumb(string file)
        {
            try
            {
                var path = System.Configuration.ConfigurationManager.AppSettings["ImageSavePath"];
                var dirPath = path + "thumb";
                var filePath = dirPath + file;
                Response.ContentType = "image/jpg";
                Response.WriteFile(filePath);
                Response.End();
                return null; 
            }
            catch (Exception)
            {
                return null;
            }
        }
        public ActionResult MoreAptitudes()
        {
            return View();
        }

        public ActionResult MoreCertificates()
        {
            return View();
        }
    }
}
